<?php

error_reporting(E_ALL);
ini_set("display_errors", 1); 
// load rss
$xml=("http://tiurtoppen.no/feed/");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
//get and output "<item>" elements
$x = $xmlDoc->getElementsByTagName('item');
$feedData = array();
for ($i = 0; $i < 2; $i++) {
    $item_title = $x->item($i)->getElementsByTagName('title')
                    ->item(0)->childNodes->item(0)->nodeValue;
    
    $item_link = $x->item($i)->getElementsByTagName('link')
                    ->item(0)->childNodes->item(0)->nodeValue;
    
    $item_desc = $x->item($i)->getElementsByTagName('description')
                    ->item(0)->childNodes->item(0)->nodeValue;
    
    $pubDate = $x->item($i)->getElementsByTagName('pubDate')
                    ->item(0)->childNodes->item(0)->nodeValue;
    $feedData[] = array(
        'url' => $item_link,
        'title' => $item_title,
        'description' => str_replace("<a href=", "<a target='_blank' href=", $item_desc),
        'pubDate' => substr(str_replace(" +0000","",$pubDate), 5)
    );
}
/*
file_put_contents("cache.txt", serialize($feedData));

$feedData = file_get_contents("cache.txt");
$feedData = unserialize($feedData);
 */
//print_r($feedData);die;

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tiurtoppen.no</title>

<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Serif|Droid+Sans" />

<style type="text/css">
body {
	margin:0px;
	padding:0px;
	font-family:'Droid Serif', Arial, Helvetica, sans-serif;
	font-size:12px;
	color:#000;
}
.headertoptext {
    color: white;
    font-family: 'Droid Serif';
    font-size: 25px;    
    position: absolute;
    margin-left: 473px;
    text-align: right;
    top: 25px;
}
.headertoptext div {
    font-size: 14px;
    margin-top: 6px;
}
.bgfooter{
    background-image: url("images/footerbg.png");
}

p {
	line-height:16px;
	margin:0px;
	padding:0px;
}
.w520 {
	width:808px;
	background:#535353;
	border:1px solid #2d2d2d;
}
.mc {
	margin:0 auto;
}
h1 {
	padding:0px;
	margin-bottom:2px;
	margin-top:0px;
	font-size:14px;
	color:#676e27;
}
h2 {
	padding:0px;
	margin-bottom:0px;
	margin-top:0px;
	font-size:16px;
	font-weight:normal;
	color:#4b4c54;
	
}
a {
	color:#676e27;
	text-decoration:none;
}
a:hover {
	text-decoration:underline;
}
img {
	border:0px;
	background:none;
}
img a {
	border:0px;
	background:none;
}
ul.menu {
	background:#5B671F;
	list-style:none;
	padding:0px;
	margin:0px;
	height:34px;
}
ul.menu li {
	float:left;
}
ul.menu li a {
	display:block;
	font-size:13px;
	color: white;
	padding:9px 25px 9px 25px;
}
ul.menu li a:hover {
	background:#818746;
	text-decoration:none;
}
ul.menu li a.curr {
	background:#818746;
}
.gray {
	color:#a5a5a5;
	margin-bottom:5px;
}
.bb {
	border-bottom:1px dotted #000;
	padding-bottom:10px;
	margin-bottom:10px;
}
.m5r {
	margin-right:5px;
}
.m5b {
	margin-bottom:5px;
}
.fl {
	float:left;
}
.white {
	color:#fff;
	font-size:11px;
	line-height:14px;
}
.white a {
	color:#fff;
}
.white a:hover {
	color:#fff;
	text-decoration:underline;
}
.topheader{
    background-color: white;
    height: 35px;    
    padding: 10px;
    width: 576px;
}
.headlogo{
    float: right;
    margin-left: -799px;
    position: absolute;
    top: 0;
}
.rightpanel{
    background-color: #ACAF81;
    /*padding: 10px; */
}
.bg_bottom {    
    margin-bottom: 0;
    padding-bottom: 5px;
    margin-top: 5px;
    color: white;
    font-weight: bolder;
}
h2{
    color: #4B4C54;
    font-size: 16px;
    font-family: 'Droid Serif', Arial,Tahoma,sans-serif;
}
ul.right_list {
    list-style: none outside none;
    margin-top: 4px;
}
ul.right_list li {
    list-style-type: square;
    margin-bottom: 7px;
    margin-left: -22px;
    padding-left: 0;
    color: white;
    font-size: 10px;
    line-height: 24px;
}
.right_list li a{
    color: white;
}

</style>

</head>
<body>
<div class="w520 mc">
  <table align="center" width="596" cellpadding="0" cellspacing="0">
    <tr>
      <td height="5"></td>
    </tr>
    <tr>
        <td>
            <img src="images/header_bg.png" width="796" alt="" />
            <img src="images/logo.png" class="headlogo" alt="logo" />
            <div class="headertoptext">
                Vi er ikke som alle andre
                <div>
                    Det er ikke hyttene våre heller
                </div>
                
            </div>
        </td>
    </tr>
    <tr>
      <td valign="top"><ul class="menu">
          <li><a href="#" class="curr">Velkommen</a></li>
          <li><a target="_blank" href="http://tiurtoppen.no/hyttebilder/">Hyttebilder</a></li>
          <li><a target="_blank" href="http://tiurtoppen.no/interiorbilder-fra-hyttene/">Interiørbilder</a></li>
          <li><a target="_blank" href="http://tiurtoppen.no">Tiurtoppen.no</a></li>
          <div style="clear:left;"></div>
        </ul></td>
    </tr>
    <tr>
      <td><img src="images/flash_img.jpg" width="796" alt="" /></td>
    </tr>
  </table>

    <table border="0" cellpadding="0" cellspacing="0" width="802" style="padding-left:6px;">
        <tr>
            <td width="596" valign="top" bgcolor="white">
                <!-- start main content -->    
                    <div class="topheader">
                        <h1 style="color:#4b4c54;font-size: 28px;">Velkommen til TiurToppen Hytter!</h1>
                    </div>      
                  <table width="596" cellpadding="10" cellspacing="0" bgcolor="#FFFFFF" align="left">

                    <tr>
                      <td>        
                        <?php foreach($feedData as $v) { ?>
                            <div class="bb">
                              <h1><a target="_blank" href="<?php echo $v['url'];?>"><?php echo $v['title'];?></a></h1>
                              <p class="gray"><?php echo $v['pubDate'];?> </p>
                              <p><?php echo $v['description'];?><br style="clear:left" /></p>
                            </div>
                        <?php  } ?>
                      </td>
                    </tr>
                  </table>
                  


                <!-- end of main content -->
            </td>
            <td class="rightpanel" valign="top">
                <div style="padding:10px; background-color: #939A67;">
                <!-- start the news -->
                <h2 class="bg_bottom">Nyheter </h2>
                <ul class="right_list">
                <?php foreach($feedData as $v) { ?>                                
                        <li>
                            <a target="_blank" href="<?php echo $v['url'];?>">
                                <?php echo $v['title'];?>
                            </a>
                        </li>                         
                <?php  } ?>
                </ul>
                <!-- end of the news -->
                </div>
                <div style="padding:10px;">
                <!-- start the like box -->
                <iframe style="margin-left:10px" width="170" height="323" scrolling="no" frameborder="0"
                        allowTransparency="true"
                        src="http://www.connect.facebook.com/widgets/fan.php?api_key=c6a7273bdf0a76b0b314d531d842ae01&id=138641666241172&name=&width=200&height=500&connections=249&stream=&logobar=&css=http://tiurtoppen.no/wp-content/themes/st_tiurtoppen/css/fb_likebox.css?1=4">
                </iframe>
                <!-- end of the like box -->
                </div>
            </td>
        </tr>
    </table>

    <table width="796" align="center" cellpadding="5" cellspacing="0" class="bgfooter">
                    <tr>
                      <td width="24%" align="left" valign="top"><p class=""><b>Hovedkontor:</b><br />
                          Industrigata 13, 2619 Lillehammer</p></td>
                      <td width="1%">&nbsp;</td>
                      <td width="24%" align="left" valign="top"><p class=""><b>Salgskontor:</b><br />
                          Holmengaten 6, 1394 Nesbru </p></td>
                      <td width="1%">&nbsp;</td>
                      <td width="24%" align="left" valign="top"><p class=""><b>Postadresse:</b><br />
                          Postboks 146, 1378 Nesbru</p></td>      
                      <td width="1%">&nbsp;</td>
                      <td width="24%" align="left" valign="top"><p class=""><b>Telefon:</b><br />
                          974 91 455</p>      
                      <p class=""><b>E-post:</b><br />
                          <a style="color:black;" href="mailto:post@tiurtoppen.no">post@tiurtoppen.no</a></p>
                      </td>
                    </tr>
                  </table>
</div>
    
    <div id="fb-root" style="display: none;"></div>
    <script src="http://connect.facebook.net/en_US/all.js#appId=336889536326720&amp;xfbml=1"></script>
    <script type="text/javascript" charset="utf-8">
        FB.Canvas.setSize({ width: 810, height: 1200 });
    </script>
    <script type="text/javascript" src="http://apis.google.com/js/plusone.js">
        {lang: 'no'}
    </script> 
    
</body>
</html>
